Ext.define('Seq.Date', {
    singleton: true,

    joda2pv(joda) {
        joda = joda.toLowerCase();
        let pt = joda.split(/[0-9]+/), d = joda.split(/[a-zA-Z]+/)[1];
        let res = {
            v: d
        };
        if ('pt' == pt[0]) {
            switch (pt[1]) {
                case 's':
                    res.p = Ext.Date.SECOND;
                    break;
                case 'm':
                    res.p = Ext.Date.MINUTE;
                    break;
                case 'h':
                    res.p = Ext.Date.HOUR;
                    break;
            }
        } else {
            switch (pt[1]) {
                case 'd':
                    res.p = Ext.Date.DAY;
                    break;
                case 'w':
                    res.v = d * Ext.Date.DAYS_IN_WEEK;
                    res.p = Ext.Date.DAY;
                    break;
                case 'm':
                    res.p = Ext.Date.MONTH;
                    break;
                case 'y':
                    res.p = Ext.Date.YEAR;
                    break;
            }
        }
        return res;
    }
});